<?php
/**
 * The template for displaying Category pages
 *
 * @link http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>
<div id="page" class="container">
	<div id="main">
	<div id="main-content" class="main-content">
	<?php the_breadcrumb(); ?>
		<div class="row main-list-wrapper">
			<div class="col-md-9">
				<div class="product-grid">
					<div class="title">
						<p class="name">Tài sản đấu giá</p>
						<?php
							$cat_id = get_term_by( 'slug', 'tai-san-dau-gia', 'category' )->term_id;
							$category_link = get_category_link( $cat_id );
						?>
					</div>
					<?php query_posts('posts_per_page=12&category_name=tai-san-dau-gia&orderby=desc'.'&paged='.$paged); ?>
					<?php if (have_posts()): while (have_posts()) : the_post(); ?>
					<div class="product-grid-item">
						<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>">
							<?php if ( has_post_thumbnail() ):the_post_thumbnail('home-thumnails'); else: ?>
							<img src="<?php echo get_template_directory_uri().'/images/no_image.jpg'?>" title="no image">
							<?php endif;?>
						</a>
						<div class="product-grid-item-content">
							<p class="name-item"><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></p>
							<div class="short-details">
								<p><span>Mã tài sản:</span><span><?php the_field('ma_tai_san') ?></span></p>
								<p><span>Giá khởi điểm:</span><span><?php the_field('gia_khoi_điem') ?></span></p>
								<p><span>Ngày đăng:</span><span><?php the_time('G:i, j/n/Y') ?></span></p>
								<a class="view-more" href="<?php the_permalink(); ?>">Chi tiết</a>
							</div>
						</div>
					</div>

					<?php endwhile;

						if(function_exists('wp_paginate')) {
							wp_paginate();
						}
						else {
							twentytwelve_content_nav( 'nav-below' );
						}
					else: ?>
					
					<!-- when no post -->
					<?php endif; ?>
					<?php wp_reset_query(); ?>
				</div>
			</div>
			<div class="col-md-3">
				<div class="row">
					<div class="hot-news">
						<a class="arrow-left" href="#"></a> 
						<a class="arrow-right" href="#"></a>
						<div class="swiper-container-hotnews">
							<div class="swiper-wrapper hot-news">
								<?php query_posts(array('post__in'=>get_option('sticky_posts'), 'posts_per_page'=>1)); ?>
								<?php while (have_posts()) : the_post(); ?>
									<div class="new-product swiper-slide"> 
										<?php if ( has_post_thumbnail() ):the_post_thumbnail('home-thumnails'); else: ?>
										<img src="<?php echo get_template_directory_uri().'/images/no_image.jpg'?>" title="no image">
										<?php endif;?>
										<div class="new-product-short">
											<h4><?php the_title() ?></h4>
											<p>Mã số: <?php the_field('ma_tai_san') ?></p>
											<p>Vị trí: <?php the_field('vi_tri') ?></p>
											<p>Diện tích: <?php the_field('dien_tich') ?></p>
											<p>Giá:	<?php the_field('gia_khoi_điem') ?></p>
											<a href="<?php the_permalink(); ?>"><span>Chi tiết</span></a>
										</div>
									</div>
								<?php endwhile; ?>
								<?php wp_reset_query(); ?>
							</div>
						</div>
						<div class="pagination"></div>
					  </div>
					<div class="news-wrapper">
						<div class="news">
							<p class="title">Tin Tức</p>
							<?php query_posts('posts_per_page=5&category_name=tin-tuc&orderby=desc'); ?>
							<?php if (have_posts()): while (have_posts()) : the_post(); ?>
							<div class="list-news">
								<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>">
									<span><?php the_title() ?></span>
									<span class="timer"><?php the_time('j/n/Y') ?></span>
								</a>
							</div>
							<?php endwhile;else: ?>
							<!-- when no post -->
							<?php endif; ?>
							<?php wp_reset_query(); ?>
						</div>
					</div>
					<div class="partner-wrapper">
						<?php echo do_shortcode('[rsSlider id="79"]') ?>
					</div>
					<div class="reference-wrapper">
						<div class="reference">
							<p class="title">Liên Kết</p>
							<?php 
								$page_slug ='lien-ket';
								$page_data = get_page_by_path($page_slug);
								$page_id = $page_data->ID;
								echo apply_filters('the_content', $page_data->post_content); 
							?>
						</div>
					</div>
				</div>
			</div>
		</div><!-- #content -->
	</div><!-- #primary -->

<?php
get_footer();
